package com.only4play.httpapt.common.json;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.util.Objects;

/**
 * @author liyuncong
 * @version 1.0
 * @file OpHttpAptGsonBuilder
 * @brief OpHttpAptGsonBuilder
 * @details OpHttpAptGsonBuilder
 * @date 2024-08-16
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                     NAME               DESCRIPTION
 * 2024-08-16               liyuncong          Created
 */
public class OpHttpAptGsonBuilder {

    private static final GsonBuilder INSTANCE = new GsonBuilder();
    private static volatile Gson GSON_INSTANCE;

    static {
        INSTANCE.disableHtmlEscaping();
    }

    public static Gson create() {
        if (Objects.isNull(GSON_INSTANCE)) {
            synchronized (INSTANCE) {
                if (Objects.isNull(GSON_INSTANCE)) {
                    GSON_INSTANCE = INSTANCE.create();
                }
            }
        }
        return GSON_INSTANCE;
    }
}
